<template>
	<navigator :url="`./detail?orderId=${item.id}`">
		<view class="item">
			<view class="upper">
				<view class="code">
					订单编号：{{item.orderSn}}
				</view>
				<view class="status pending" v-if="item.orderStatus == 0">
					待支付
				</view>
				<view class="status success" v-if="item.orderStatus == 1">
					已完成
				</view>
				<view class="status refund" v-if="item.orderStatus == 3">
					已退款
				</view>
				<view class="status expired" v-if="item.orderStatus == 4 || item.orderStatus == 5">
					已关闭
				</view>
			</view>
			<view class="content" v-if="item.scene == `course`">
				<view class="left" v-if="item.goodsList.length > 0">
					<image :src="item.goodsList[0].courseImageUrl" mode="aspectFill"></image>
					<view class="text">
						{{item.goodsList[0].courseName}}
						<text>优惠：-￥{{item.discountTotal}}</text>
					</view>
				</view>
				<view class="price">
					￥{{item.total}}
				</view>
			</view>
			<view class="content" v-if="item.scene == `recharge`">
				<view class="left">
					<view class="text">
						{{item.orderDesc}}
						<text>{{item.discount_info}}</text>
					</view>
				</view>
				<view class="price">
					￥{{item.total}}
				</view>
			</view>
			<view class="botoom">
				<view class="left" v-if="item.scene == `course`">
					共1份 合计：<text>{{item.paymentTotal}}元</text>
				</view>
				<view class="left" v-if="item.scene == `recharge`">
					合计：<text>{{item.paymentTotal}}元</text>
				</view>
				<view class="right">
					<text v-if="item.orderStatus == 0">取消订单</text>
					<text v-if="item.orderStatus == 4 || item.orderStatus == 5">删除订单</text>
					<text class="btn" v-if="item.orderStatus == 0">立即付款</text>
					<text class="btn" @click.stop="handleOpen" v-if="item.orderStatus == 1 && scene == `refund`">申请退款</text>
					<text class="btn" @click.stop="handleOpenS" v-if="item.orderStatus == 1 && scene == `invoice`">企业发票</text>
					<text class="btn" @click.stop="handleOpenP" v-if="item.orderStatus == 1 && scene == `invoice`">个人发票</text>
				</view>
			</view>
		</view>

	</navigator>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: {
			item: {
				default: {}
			},
			scene:{
				default:''
			}
		},
		methods: {
			handleOpen() {
				this.$emit("handleOpen",this.item.id)
			},
			handleOpenS() {
				this.$emit("handleOpenS",this.item.id)
			},
			handleOpenP() {
				this.$emit("handleOpenP",this.item.id)
			},
		}
	}
</script>

<style lang="scss">
	.item {
		background-color: #fff;
		padding: 40rpx;
		font-size: 28rpx;

		.upper {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.status {
				color: #999;
			}

			.pending {
				color: $uni-color-warning;
				font-weight: bold;
			}
			.success {
				color: $uni-color-success;
				font-weight: bold;
			}
			.expired {
				color: $uni-color-error;
				font-weight: bold;
			}
			
			
		}

		.content {
			display: flex;
			padding: 40rpx 0;
			justify-content: space-between;

			.left {
				display: flex;
				width: calc(100% - 160rpx);

				image {
					width: 140rpx;
					height: 100rpx;
					border-radius: 8rpx;
					overflow: hidden;
				}

				.text {
					font-weight: bold;
					font-size: 32rpx;
					padding-left: 10rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					text {
						display: block;
						font-size: 24rpx;
						color: #999;
						font-weight: normal;
					}
				}

			}

			.price {
				padding: 10rpx 0;
				font-size: 32rpx;
			}
		}
	}

	.botoom {
		display: flex;
		justify-content: space-between;
		align-items: center;

		.left {
			text {
				color: red;
				font-weight: bold;
			}
		}

		.right {
			display: flex;

			text {
				display: block;
				width: 120rpx;
				line-height: 44rpx;
				border: 2rpx solid #999;
				text-align: center;
				font-size: 24rpx;
				color: #999;
				border-radius: 20px;
				margin-left: 30rpx;
			}

			.btn {
				color: #fff;
				background-color: $assist-color2;
				border-color: $assist-color2;
			}
		}
	}
</style>